/**
 * Created by timxuan on 2016/11/10.
 */
/* eslint-disable */
"use strict";

import uuid from "uuid";

export let uniqueRandomStr = length => {
    return uuid
        .v1()
        .replace(/-/g, "")
        .substr(0, length);
};

/**
 * 合并对象
 * @param {object} target
 */
export let extend = target => {
    if (target === null) {
        throw new Error("target cannot be null");
    }

    let i = 0,
        len = arguments.length,
        p,
        src;

    while (++i < len) {
        src = arguments[i];
        if (src !== null) {
            for (p in src) {
                if ({}.hasOwnProperty.call(src, p)) {
                    target[p] = src[p];
                }
            }
        }
    }

    return target;
};

export default {
    uniqueRandomStr: uniqueRandomStr,
    extend: extend
};
